Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make tree-sitter feature optional #332

Merged
merged 5 commits into from
Oct 30, 2023

Conversation

jdonszelmann
Copy link
Contributor

We were using stack-graphs for a project we were working on. One of the slowest dependencies to compile was tree-sitter, and we weren't even using that part of stack-graphs! So we made the dependency optional :). The feature flag is enabled by default, so nothing changes about the public api and nobody else's code will break but for those who don't need it's a nice speedup.

@jdonszelmann jdonszelmann requested a review from a team as a code owner October 30, 2023 16:09
@hendrikvanantwerpen
Copy link
Collaborator

Hi @jdonszelmann! Thanks for the contribution. I agree that this shouldn't be pulled in by default. I'd suggest to make the change slightly differently though:

  • Change the default feature from lsp-positions to tree-sitter = ["dep:tree-sitter"]
  • Add tree-sitter feature to the lsp-positions dependency in tree-sitter-stack-graphs

This way stack-graphs will be really free from tree-sitter concerns (including not dependening on it 😉)

BTW, I'd also love to hear what you are doing with stack graphs!

@jdonszelmann
Copy link
Contributor Author

How about this?

Copy link
Collaborator

@hendrikvanantwerpen hendrikvanantwerpen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case my comment was too brief, I'll also add comments on the diff for what I have in mind :)

@@ -17,7 +17,7 @@ edition = "2018"
test = false

[features]
default = ["tree-sitter"]
default = ["dep:tree-sitter"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change default to tree-sitter here, and reorder to keep alphabetical.

@@ -13,6 +13,7 @@ authors = [
edition = "2018"

[features]
default = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove this.

@@ -32,7 +33,7 @@ enumset = "1.1"
fxhash = "0.2"
itertools = "0.10"
libc = "0.2"
lsp-positions = { version = "0.3", path = "../lsp-positions" }
lsp-positions = { version = "0.3", path = "../lsp-positions", default-features=false }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabling the default-features shouldn't be necessary anymore with the change above.

tree-sitter-stack-graphs/Cargo.toml Show resolved Hide resolved
Co-authored-by: Terts Diepraam [email protected]
@jdonszelmann
Copy link
Contributor Author

This should be all your suggestions (some were already covered in the previous commits)

@jdonszelmann
Copy link
Contributor Author

Also, where would you like to hear what we use it for? :P

Copy link
Collaborator

@hendrikvanantwerpen hendrikvanantwerpen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was one left, and a small style nit.

@@ -32,7 +32,7 @@ enumset = "1.1"
fxhash = "0.2"
itertools = "0.10"
libc = "0.2"
lsp-positions = { version = "0.3", path = "../lsp-positions" }
lsp-positions = { version = "0.3", path = "../lsp-positions"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit Keep the space at the end as well.

Comment on lines 20 to 21
default = ["dep:tree-sitter"]
bincode = ["dep:bincode"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
default = ["dep:tree-sitter"]
bincode = ["dep:bincode"]
bincode = ["dep:bincode"]
tree-sitter = ["dep:tree-sitter"]

@jdonszelmann
Copy link
Contributor Author

ah I see, good to see that you're thorough on this haha, hope this is finally it.

@hendrikvanantwerpen
Copy link
Collaborator

Also, where would you like to hear what we use it for? :P

You can start a show and tell discussion on this repo, or send me an email, whatever you prefer!

Copy link
Collaborator

@hendrikvanantwerpen hendrikvanantwerpen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good!

@hendrikvanantwerpen hendrikvanantwerpen merged commit d6e60f6 into github:main Oct 30, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants